package com.web;

import com.pojo.Yuyue_lfy;
import com.service.Yuyue_lfyService;
import com.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/yuyue")
public class Yuyue_lfyController {
    @Autowired
    private Yuyue_lfyService yService;
    @RequestMapping("/insert")
    public ResultEntity insertInfo(@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("yuyueTime")Date yuyueTime,
                                    @RequestParam("yuyueUid") Integer yuyueUid,
                                   @RequestParam("yuyueType") String yuyueType,
                                   @RequestParam("yuyueContent") String yuyueContent) {
        return ResultEntity.ok(yService.insertInfo(yuyueTime, yuyueUid, yuyueType, yuyueContent));
    }

    @RequestMapping("/select")
    public ResultEntity selectAll() {
        return ResultEntity.ok(yService.selectAll());
    }

    @RequestMapping("/delete")
    public ResultEntity delete(@RequestParam("id") Integer yuyueId) {
        return ResultEntity.ok(yService.delete(yuyueId));
    }

    @RequestMapping("/searchTime")
    public ResultEntity searchTime(@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("time")Date yuyueTime,
                                  @RequestParam("name") String username) {
        return ResultEntity.ok(yService.searchTime(yuyueTime, username));
    }

    @RequestMapping("/update")
    public ResultEntity updateInfo(Yuyue_lfy yuyue_lfy) {
        return ResultEntity.ok(yService.updateInfo(yuyue_lfy));
    }
}
